home *** CD-ROM | disk | FTP | other *** search
- /* main.c - This file demonstrates how to call
- the Bleu Rose Ltd. Error Library
-
- Copyright 2000 Bleu Rose Ltd. All Rights Reserved.
-
- Author: Gary Rice
-
- Created: September 9, 2000 - Development environment:
- CodeWarrior/Pro v5.3
- Mac OS v7.6.1
-
- Modified: N/A
-
- Licensing Notes:
- You may incorporate this source code into your
- applications without restriction.
-
- You are NOT permitted to redistribute the source,
- compiled binaries or the library that the code
- references without first licensing the package
- represented by this source file from Bleu Rose Ltd.
-
- Licensing information was packaged with the files
- that this file was part of. If that licensing information
- is no longer included in the files you have, you may obtain
- another copy by sending EMail to licensing@bleurose.com
- and asking for the Error Library Licensing Package.
-
- Usage Notes:
- This file is compatible with Universal Headers v3.2 and later..
- It assume MacHeaders.h is the default include file.
-
- *****************************************************************/
-
- /* Include the Error definition interface file */
- #include "BleuRoseErrors.h"
-
- /* Prototypes */
- void Initialize (void);
- int main (void);
-
- /* Here's all you have to do */
- int main (void)
- {
- FSSpec theErrorLibrary;
- BleuRoseErrorLibStructure theError;
- OSStatus result;
- Str255 p1;
- Str255 p2;
- Str255 p3;
- Str255 p4;
-
- Initialize(); /* Standard stuff */
-
- /* Locate the Bleu Rose Error Library */
- result = FindBleuRoseErrorLibrary (&theErrorLibrary);
-
- /* If we found the library, look up the rquested error */
- if (result == (OSStatus)noErr)
- {
- /*-------------- v Your Code Goes Here v -------------------------------------------
- The following 2 lines of code are the only things you really need
- to fill in from your own source. The first is the actual error you
- want to look up. The second is the Error Type you think might be
- the source of the error. If you don't know, just fill in a zero.
- An error type would be a "QuickTime", "Location Manager",
- "File System", etc. error. Many Mac OS error numbers have multiple
- meanings. This error type value helps distinguish one from another. */
- theError.error = -199; /* Replace this # with your
- own error value */
- theError.proposedErrorTypeNumber = k1stErrorTypeFound; /* Find the first
- occurrence of the error
- ----------------- ^ Your Code Goes Here ^ ----------------------------------------- */
-
- /* Look the error up */
- theError.action = kGetError;
- result = CallBleuRoseErrorLibrary (&theErrorLibrary, &theError);
- }
-
- /* If there was a problem, say so. Otherwise, set up to display the
- error that was found in the library */
- BlockMoveData ("\perror", p4, 6);
- if (result)
- {
- /* Was it a system error or a Library error? */
- if (result < kWarningLibraryNotLicensed && /* smallest Bleu Rose warning value */
- result > kErrorNoDescResMissing) /* largest Bleu Rose Error value */
- {
- BlockMoveData ("\pthere was a problem accessing the Bleu Rose Error Library", p1, 58);
- BlockMoveData ("\pMac OS", p3, 7);
- }
- else
- {
- BlockMoveData ("\pBleu Rose Library", p3, 18);
- switch (result)
- {
- case kWarningErrorNotRequestedType:
- BlockMoveData ("\pthe error doesn't match the type requested", p1, 43);
- break;
- case kWarningErrorNotDescribed:
- BlockMoveData ("\pthe error has no description", p1, 29);
- break;
- case kWarningErrorNotDescribedAndNotRequestedType:
- BlockMoveData ("\pthe error is not the type you requested and the error has no description", p1, 73);
- break;
- case kWarningLibraryNotLicensed:
- BlockMoveData ("\pthe library has not yet been licensed", p1, 38);
- break;
-
- case kErrorNotOnFile:
- BlockMoveData ("\pthe error requested was not found", p1, 34);
- break;
- case kErrorTypeOutOfRange:
- BlockMoveData ("\pthe error type you requested is not valid", p1, 42);
- break;
- case kErrorTypeNotOnFile:
- BlockMoveData ("\pthe error type requested was not found", p1, 39);
- break;
- case kErrorTypeResMissing:
- BlockMoveData ("\pthe error type STR# resource is missing", p1, 40);
- break;
- case kErrorResMissing:
- BlockMoveData ("\pthe error TEXT resource is missing. The library has probably NOT been populated", p1, 80);
- break;
- case kErrorNoDescResMissing:
- BlockMoveData ("\pthe 'no description' resource is missing", p1, 41);
- break;
- }
- }
-
- if (result > 0)
- BlockMoveData ("\pwarning", p4, 8);
-
- NumToString (result, p2);
- ParamText (p1, p2, p3, p4);
- }
- else
- {
- NumToString (theError.error, p2);
- ParamText (theError.description, p2, theError.errorTypeName, p4);
- }
-
- /* Display the error found or the failure message */
- Alert (128, 0L);
- return 0;
- }
-
- /* Initialize the standard Mac OS Managers */
- void Initialize (void)
- {
- #if TARGET_API_MAC_CARBON
- MoreMasters ();
- #else
- MaxApplZone ();
- MoreMasters ();
-
- InitGraf (&qd.thePort);
- InitFonts ();
- InitWindows ();
- InitMenus ();
- TEInit ();
- InitDialogs (nil);
- #endif
- InitCursor ();
- }